Skip to content

fix 2 problems plus add workaround for #13760 #14252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2022
Merged

fix 2 problems plus add workaround for #13760 #14252

merged 1 commit into from
Jan 12, 2022

Conversation

philwalk
Copy link
Contributor

@philwalk philwalk commented Jan 11, 2022

replaces #14241

These changes fix 2 problems, and add a workaround for #13760.

  • script exceptions are discarded by MainGenericRunner, when running from a compiled jar.
  • when the -save option is not specified at runtime, execution should not be from a previously compiled jar

The -save behavior matches the expectation in scala2.

This PR displays all exceptions on the Console when running from a jar file.

This PR executes from the jar only if the -save option is specified at runtime. Problem scripts (i.e., with references to java.sql.Date) can now selectively disable the -save option.

The -save option change provides a workaround for the ClassNotFound: java.sql.Date problem, which affects jdk 9+.

`java.lang.ClassNotFoundException: java.sql.Date`

A new command line option -nosave is provided, for undoing a -save option on the command line (e.g., inSCALA_OPTS) This provides a way for individual scripts to override the -save option.

Adding -save to SCALA_OPTS will typically reduce script startup time by a couple of seconds. This PR provides per-script granularity for overriding the '-save' option. Scripts that would otherwise throw an exception when running from a compiled jar may specify -nosave in the hashbang line. This avoids having to remove the -save option from SCALA_OPTS.

The -nosave option can be added to the hashbang line, as in these two example hashbang lines:

The first version requires /usr/bin/env version 8.30 or later:

#!/usr/bin/env -S scala -nosave

This version uses the path to the scala wrapper:

#!/opt/scala3/bin/scala -nosave

Copy link
Contributor

@BarkingBad BarkingBad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BarkingBad BarkingBad merged commit 0a834ff into scala:master Jan 12, 2022
@philwalk philwalk deleted the fixes-with-workaround-for-13760 branch January 16, 2022 19:24
@Kordyjan Kordyjan added this to the 3.1.2 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants